const { defineConfig } = require('@vue/cli-service');

module.exports = defineConfig({
  publicPath: './',
  devServer: {
    allowedHosts: 'all'
  },
  productionSourceMap: false,
  configureWebpack: {
    optimization: {
      minimize: true // 启用代码压         
    }
  },
  chainWebpack: config => {
    // 添加Vue特性标志
    config.plugin('define').tap((args) => {
      args[0].__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ = JSON.stringify(false);
      return args;
    });
    
    // 添加Terser配置
    config.optimization.minimizer('terser').tap((args) => {
      args[0].terserOptions = {
        ...args[0].terserOptions,
        compress: {
          ...(args[0].terserOptions?.compress || {}),
          drop_console: true,
        }
      };
      return args;
    });
    return config;
  },
  transpileDependencies: true,
  css: {
    loaderOptions: {
      sass: {
        additionalData: `@import "@/styles/var.scss";@import "@/styles/common.scss";`
      }
    }
  }
})
